<%@page language="java" isELIgnored="false" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<jsp:directive.include file="/WEB-INF/sitemesh-decorators/include.jsp"/>
<fmt:setBundle basename="bundles.facultyresearch-resources"/>
<html>
<head>
<title>Edit <fmt:message key="facultyresearch.title"/> <fmt:message key="facultyresearchtostudent.title"/></title>
<script type="text/javascript">
var tempStr2="";
$(function() {
	var categoryList = '${studentList}';
	var catStr = categoryList.substring(categoryList.indexOf('{')+1,categoryList.indexOf('}'));
	catStr = catStr.replace(/=/g,":");
	var categoryArr=catStr.split(',');
	var tempArray = new Array();
	var tempStr="";
	for(var i=0;i<categoryArr.length;i++){
		categoryArr[i] = categoryArr[i].replace(/\|/,", ");
		tempStr = categoryArr[i];
		tempStr = tempStr.substring(tempStr.indexOf(":")+1);
		tempArray[i]= tempStr;
	}
	var tempStr1="";
	
	var categoryList2 = '${facultyList}';
	var catStr2 = categoryList2.substring(categoryList.indexOf('{')+1,categoryList.indexOf('}'));
	catStr2 = catStr2.replace(/=/g,":");
	var categoryArr2=catStr2.split(',');
	var tempArray2 = new Array();
	var tempStr2="";
	for(var i=0;i<categoryArr2.length;i++){
		categoryArr2[i] = categoryArr2[i].replace(/\|/,", ");
		tempStr2 = categoryArr2[i];
		tempStr2 = tempStr2.substring(tempStr2.indexOf(":")+1);
		tempArray2[i]= tempStr2;
	}
	var tempStr2="";
	
	
	$( "#facultyresearchtostudent_student").autocomplete({
		source: tempArray,
		select: function(e, ui) {
			var cat = ui.item.value;
			getId(cat,categoryArr,'facultyresearchtostudent_studentId');
			$("#facultyresearchtostudent_student").val(cat);
		},
		close: function(event, ui) {
		}
	});
	
	$( "#facultyresearchtostudent_faculty").autocomplete({
		source: tempArray2,
		select: function(e, ui) {
			var cat = ui.item.value;
			getId(cat,categoryArr2,'facultyresearchtostudent_facultyId');
			
			$("#facultyresearchtostudent_faculty").val(cat);
		},
		close: function(event, ui) {
		}
	});
	
});
	
function getId(str,arr,inp){
	var key = "";
	var value ="";
	var tempStr="";
	for(var i=0;i<arr.length;i++){
		tempStr = arr[i];
		tempStr = tempStr.replace(/^\s+|\s+$/g,'');
		key=tempStr.substring(0,tempStr.indexOf(":"));
		value = tempStr.substring(tempStr.indexOf(":")+1);
		if(value==str){
			//alert(inp+" "+key);
			$("#"+inp).val(key);
		}
	}
}
$(document).ready(function() {
	$("#facultyresearchtostudent_facultyId").val('${facultyId}');
	});
</script>
</script>
</head>
<body>
<div id="contentarea">   
<script type="text/javascript">
$().ready(function() {
	$('#facultyresearchtostudentform').validate();
});
</script>   
	<div id="lb"><div id="rb"><div id="bb"><div id="blc">
	<div id="brc"><div id="tb"><div id="tlc"><div id="trc">
	<div id="content">
		<h1><%-- <fmt:message key="navigation.edit"/> --%> <fmt:message key="facultyresearchtostudent.title"/></h1>
		<div class="navitem"><a class="button" href="${pageContext.request.contextPath}/selectFacultyresearch?facultyResearchIdKey=${facultyresearch_facultyResearchId}&"><span><img src="includes/images/icons/back.gif" /><fmt:message key="navigation.back"/></span></a></div>
		<form:form id="facultyresearchtostudentform" action="${pageContext.request.contextPath}/saveFacultyresearchFacultyresearchtostudents" method="POST" modelAttribute="facultyresearchtostudent">
			<form:hidden id="facultyresearchtostudent_facultyResearchId" path="facultyResearchId"/>
			<form:hidden id="facultyresearchtostudent_studentId" path="studentId"/>
			<form:hidden id="facultyresearchtostudent_facultyId" path="facultyId"/>
			<table cellpadding="0" cellspacing="0" id="viewTable">
				<tbody>
									
					<tr>
						<td class="label" valign="top">
							<fmt:message key="facultyresearchtostudent.studentid.title"/>:
						</td>
						<td>
							<c:choose>
								<c:when test='${newFlag}' >
							<input type="text" id="facultyresearchtostudent_student" style="width:300px;" class="required"/>
								</c:when>
								<c:otherwise>
							<%-- ${facultyresearchtostudent.studentId} --%>
							${facultyresearchtostudent.student.firstName}${facultyresearchtostudent.student.lastName}
						&nbsp;
									
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
					<%-- <tr>
						<td class="label" valign="top">
							<fmt:message key="facultyresearchtostudent.facultyid.title"/>:
						</td>
						<td>
							<c:choose>
								<c:when test='${newFlag}' >
							<input type="text" id="facultyresearchtostudent_faculty" style="width:300px;"/>
								</c:when>
								<c:otherwise>
							${facultyresearchtostudent.facultyId}
						&nbsp;
									
								</c:otherwise>
							</c:choose>
						</td>
					</tr>--%>
				</tbody>
			</table>
			<span class="inputbutton"><input class="savebutton" id="save" type="submit" value="<fmt:message key="navigation.save"/>"/></span>
			<script type="text/javascript">Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'save', event:'onclick'}));</script>
				<input type="hidden" name="facultyresearch_facultyResearchId" value="${facultyresearch_facultyResearchId}" >
				
				
				
				
		</form:form>
		<div class="clear">&nbsp;</div>
	</div>
	</div></div></div></div>
	</div></div></div></div>
</div>
</body>
</html>
